<?php
include("db_connect.php");
$data = array();

if(isset($_GET['approve'])){
	
	if($_GET['approve'] == "approve"){
		approve();
	}
	else{
		disapprove();
	}
	
}


function approve(){
	$userid = $_GET['itemRequest'];
	$data = explode("," , $userid);
	$y= count($data);
	$timepost = date("M-j-Y / h:i:s A"); 
	$x =1;
	for($i=0; $i<=$y-1; $i++ ){
		
			$sql = "UPDATE tblswaping SET display= '$x', timepost ='$timepost'  WHERE id = ".$data[$i]." "; 
			mysql_query($sql);
	}
	echo $sql ."+" .$userid;
	if(mysql_affected_rows() ){
		echo " 1 ";
	}
	else{
		echo $sql;
	}
}

function disapprove(){
	$userid = $_GET['itemRequest'];
	$data = explode("," , $userid);
	$y= count($data);
	$x = 0;
	for($i=0; $i<=$y-1; $i++ ){
		
			$sql = "UPDATE tbltradein SET display='".$x."' where id= ".$data[$i]." "; 
			mysql_query($sql);
	}

	if(mysql_affected_rows() ){
		echo " 1 ";
	}
	else{
		echo $sql;
	}
}

?>